package windowstart;

import java.awt.*;  
import java.awt.event.*;  
import javax.swing.*;
import chess.ChessBoard;
import com.rockzhai.ai.Ai;
import com.rockzhai.ai.DrawingPanel;

//本人Gitee主页：https://gitee.com/mimocvb
public class windowsmain {  
    public static void main(String[] args)  
    {  
        EventQueue.invokeLater(()->{  
                    JFrame frame=new ButtonFrame();  
                    frame.setTitle("五子棋");  
                    frame.setUndecorated(false);
                    frame.setResizable(false);
                    frame.setVisible(true);  
                }  
        ); 
        Ai.main(null);
    }  
}  
class ButtonFrame extends JFrame {  
	
	Font f = new Font("微软雅黑",Font.BOLD,15);
	
	private static final long serialVersionUID = 1L;
    private JButton chessA;
    private JButton aiA;
    private JButton about;
    
    public ButtonFrame(){ 
    	
    	//鼠标样式
    	Toolkit kit=Toolkit.getDefaultToolkit();
    	Image img=kit.getImage("file/mouse.png");
    	Cursor mouse=kit.createCustomCursor(img, new Point(1,1), "stick");
		setCursor(mouse);
    	
    	//设置窗口控件风格，更加圆润
    	try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        }catch(Exception e) {
        	System.out.println(e);
        }
    	
        setSize(300,350);  
 
        MODAction lis = new MODAction();
        
        chessA = new JButton("普通双人对弈");  
        aiA = new JButton("AI先手对弈"); 
        about = new JButton("关于"); 

        chessA.addActionListener(lis);
        aiA.addActionListener(lis);
        about.addActionListener(lis);
        
        setLayout(null);
        
        chessA.setFont(f);
        aiA.setFont(f);
        about.setFont(f);
        chessA.setBounds(7, 5, 280, 120);
        aiA.setBounds(7, 130, 280, 120);
        about.setBounds(7, 255, 280, 60);
        
        setIconImage(new ImageIcon("file/icon.png").getImage());
        
        getContentPane().add(chessA);
        getContentPane().add(aiA);
        getContentPane().add(about);
        
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
    }  
 
    private class MODAction implements ActionListener{  
    	public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			Object obj = e.getSource();
			if (obj == chessA)
			{
				ChessBoard.xianshi();
			}
			else if (obj == aiA)
			{

				DrawingPanel.xianshi();
					
			}
			else if(obj == about){
				
				String s = String.format("【五子棋】\n" + "\n视觉Swing设计：咪沫\n" + "程序逻辑及AI算法设计：咪沫\n" + "\n其余作品请百度搜索：咪沫\nGitee主页：https://gitee.com/mimocvb");
				
	    		JOptionPane.showMessageDialog(null, s,"关于",JOptionPane.INFORMATION_MESSAGE);
				
			}
        }
    }
}  